Last updated: 2019-07-04

Checks: 4 2

Knit directory: diffNet/

This reproducible R Markdown analysis was created with workflowr (version 1.3.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown is untracked by Git. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20190331) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

The following chunks had caches available:
  • unnamed-chunk-1
  • unnamed-chunk-3
  • unnamed-chunk-4

To ensure reproducibility of the results, delete the cache directory W_and_V_alt_cache and re-run the analysis. To have workflowr automatically delete the cache directory prior to building the file, set delete_cache = TRUE when running wflow_build() or wflow_publish().

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    R/.DS_Store
    Ignored:    R/.Rhistory
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/simulation3_files/
    Ignored:    analysis/simulation3_realA_files/
    Ignored:    docs/.DS_Store
    Ignored:    docs/figure/.DS_Store
    Ignored:    src/.DS_Store

Untracked files:
    Untracked:  .Rprofile
    Untracked:  .gitignore
    Untracked:  R/get_MLstat.R
    Untracked:  R/not_build/
    Untracked:  R/post_score.R
    Untracked:  R/utilities_wv.R
    Untracked:  analysis/._.DS_Store
    Untracked:  analysis/._AA.Rmd
    Untracked:  analysis/._AA_EA.Rmd
    Untracked:  analysis/._correction.Rmd
    Untracked:  analysis/TFs.Rmd
    Untracked:  analysis/TFs.pdf
    Untracked:  analysis/W_and_V.Rmd
    Untracked:  analysis/W_and_V_alt.Rmd
    Untracked:  analysis/W_and_V_alt_cache/
    Untracked:  analysis/figure/
    Untracked:  analysis/simulation4_cache/
    Untracked:  analysis/simulation5.Rmd
    Untracked:  analysis/simulation5_results/
    Untracked:  analysis/unscale.R
    Untracked:  code/data_generating.R
    Untracked:  code/different_models.R
    Untracked:  constant_variance_check.R
    Untracked:  data/
    Untracked:  docs/figure/liquid_assoc.Rmd/
    Untracked:  docs/figure/simulation1.Rmd/
    Untracked:  docs/figure/simulation2.Rmd/
    Untracked:  docs/figure/simulation3.Rmd/
    Untracked:  docs/figure/simulation4.Rmd/
    Untracked:  man/get_score_W_c.Rd
    Untracked:  man/h1_fisher.Rd
    Untracked:  man/h2_linear.Rd
    Untracked:  man/h3_cdf.Rd
    Untracked:  man/likelihood_cdf.Rd
    Untracked:  man/likelihood_fisher.Rd
    Untracked:  man/likelihood_linear.Rd
    Untracked:  man/likelihood_null.Rd
    Untracked:  man/post_score.Rd
    Untracked:  old_analysis/
    Untracked:  simulation_n30_fisher_0.1.RData
    Untracked:  simulation_n30_fisher_0.2.RData
    Untracked:  simulation_n30_fisher_0.3.RData
    Untracked:  simulation_n30_fisher_0.4.RData
    Untracked:  simulation_n30_fisher_0.5.RData
    Untracked:  simulation_n30_fisher_0.RData
    Untracked:  simulation_n30_fisher_1.5.RData
    Untracked:  simulation_n30_fisher_1.RData
    Untracked:  simulation_n30_fisher_2.RData
    Untracked:  simulation_n30_sin_0.2.RData
    Untracked:  simulation_n30_sin_0.25.RData
    Untracked:  simulation_n30_sin_0.3.RData
    Untracked:  simulation_n30_sin_0.4.RData
    Untracked:  simulation_n30_sin_0.5.RData
    Untracked:  simulation_n30_sin_0.75.RData
    Untracked:  simulation_n30_sin_0.RData
    Untracked:  simulation_n30_sin_1.5.RData
    Untracked:  simulation_n30_sin_1.RData
    Untracked:  simulation_n30_sin_2.RData
    Untracked:  simulation_n30_sin_3.RData
    Untracked:  src/._Makevars
    Untracked:  src/Makevars

Unstaged changes:
    Modified:   .Rbuildignore
    Modified:   DESCRIPTION
    Modified:   NAMESPACE
    Modified:   R/get_score.R
    Modified:   analysis/AA.Rmd
    Modified:   analysis/AA_EA.Rmd
    Deleted:    analysis/AA_vs_EA_skin_not_sun_exposed.Rmd
    Deleted:    analysis/AA_vs_EA_skin_not_sun_exposed.pdf
    Modified:   analysis/correction.Rmd
    Deleted:    analysis/index.Rmd
    Deleted:    analysis/license.Rmd
    Deleted:    analysis/score_test.R
    Modified:   man/get_score_w_c.Rd
    Modified:   src/RcppExports.cpp
    Modified:   src/RcppExports.o
    Deleted:    src/diffNet.so
    Modified:   src/utilities.cpp
    Modified:   src/utilities.o

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


There are no past versions. Publish this analysis with wflow_publish() to start tracking its development.


Simulate X

n = 30
X = scale(rnorm(n)) * sqrt(n) / sqrt(n-1)
X = cbind(rep(1, n), X)
B = 1000

Simulation under Fisher

power = c("LM", "LA", "Fisher")
for (a in c(0, 0.5, 1, 1.5, 2)){
  if(a==0){
    rho = runif(1,-1,1)
  }
  else{
    alpha = c(0, a)
    rho = h1_fisher(X, alpha)
  }
  out = do_sim(X = X, n = n, B = B, rho = rho, mles = TRUE)
  save(out, file = paste0("simulation_n30_fisher_", a, ".RData"))
  power = cbind(power, powercheck(out, B = B, n = a)[,2])
}
print(power)
     power                                           
[1,] "LM"     "0.052" "0.206" "0.542" "0.795" "0.91" 
[2,] "LA"     "0.054" "0.18"  "0.511" "0.722" "0.828"
[3,] "Fisher" "0.046" "0.247" "0.693" "0.965" "0.992"
newX = cbind(rep(1, 1000), sort(runif(1000, -2.5, 2.5)))
df = data.frame(alpha1 = h1_fisher(newX, c(0,0.5)),
                alpha2 = h1_fisher(newX, c(0,1)),
                alpha3 = h1_fisher(newX, c(0,1.5)),
                alpha4 = h1_fisher(newX, c(0,2)))
df = melt(df)
No id variables; using all as measure variables
df$X = rep(newX[,2], 4)
levels(df$variable) = c("0.5", "1", "1.5", "2")
colnames(df)[1] = "alpha"
ggplot(df, aes(x = X, y = value, col = alpha)) + geom_line() + labs(color=expression(alpha))  +
  ylab(expression(rho)) +
  xlab(expression(X)) +
  theme_bw(base_size=12)+
  ggtitle("tanh")

ggsave("fisher.png", height = 3, width = 3)

Simulation under Quadratic Function

power = c("LM", "LA", "Fisher")
for (a in c(0.2, 0.3, 0.4, 0.5)){
  if(a==0){
    rho = runif(1,-1,1)
  }
  else{
    alpha = c(0, a)
    rho = h6_quadratic(X, alpha)
    rho = pmin(0.99, rho); rho = pmax(-0.99, rho)
  }
  out = do_sim(X = X, n = n, B = B, rho = rho, mles = TRUE)
  save(out, file = paste0("simulation_n30_sin_", a, ".RData"))
  power = cbind(power, powercheck(out, B = B, n = a)[,2])
}
print(power)
     power                                   
[1,] "LM"     "0.627" "0.587" "0.539" "0.531"
[2,] "LA"     "0.042" "0.047" "0.058" "0.079"
[3,] "Fisher" "0.533" "0.438" "0.371" "0.338"
newX = cbind(rep(1, 1000), sort(runif(1000, -2.5, 2.5)))
df = data.frame(alpha1 = h6_quadratic(newX, c(0,0.2)),
                alpha2 = h6_quadratic(newX, c(0,0.3)),
                alpha3 = h6_quadratic(newX, c(0,0.4)),
                alpha4 = h6_quadratic(newX, c(0,0.5)))

df = melt(df)
No id variables; using all as measure variables
df$X = rep(newX[,2], 4)
levels(df$variable) = c("0.2", "0.3", "0.4", "0.5")
colnames(df)[1] = "alpha"
ggplot(df, aes(x = X, y = value, col = alpha)) + geom_line() +labs(color=expression(alpha))  +
  ylab(expression(rho)) +
  xlab(expression(X)) +
  theme_bw(base_size=12)+
  ggtitle("quadratic")

ggsave("quadratic.png", width=3, height=3)

Time comparison

t_la = out$t_la
t_fisher = out$t_fisher
t_lm = out$t_lm

df = data.frame(score = log10(t_lm),
                LR = log10(t_fisher),
                LA = log10(t_la))
ggplot(melt(df), aes(x=variable, y=value)) + 
  geom_violin() + 
  ylab(expression(log[10]~time)) + 
  xlab("") + 
  ylim(c(-5, -1)) + 
  ggtitle("computation time")
No id variables; using all as measure variables


sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.2 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ggplot2_3.1.1      reshape2_1.4.3     diversitree_0.9-11
[4] ape_5.3           

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.1                compiler_3.5.3           
 [3] pillar_1.3.1              git2r_0.25.2             
 [5] plyr_1.8.4                workflowr_1.3.0          
 [7] tools_3.5.3               digest_0.6.18            
 [9] evaluate_0.13             tibble_2.1.1             
[11] nlme_3.1-138              gtable_0.3.0             
[13] lattice_0.20-38           pkgconfig_2.0.2          
[15] rlang_0.3.4               yaml_2.2.0               
[17] parallel_3.5.3            xfun_0.6                 
[19] RcppArmadillo_0.9.300.2.0 withr_2.1.2              
[21] stringr_1.4.0             dplyr_0.8.0.1            
[23] knitr_1.22                fs_1.2.7                 
[25] tidyselect_0.2.5          rprojroot_1.3-2          
[27] grid_3.5.3                deSolve_1.21             
[29] glue_1.3.1                R6_2.4.0                 
[31] rmarkdown_1.12            purrr_0.3.2              
[33] magrittr_1.5              backports_1.1.3          
[35] scales_1.0.0              codetools_0.2-16         
[37] htmltools_0.3.6           assertthat_0.2.1         
[39] colorspace_1.4-1          labeling_0.3             
[41] subplex_1.5-4             stringi_1.4.3            
[43] lazyeval_0.2.2            munsell_0.5.0            
[45] crayon_1.3.4